package com.yidu.t299.service.xp.impl;
import com.yidu.t299.dao.xp.StudentManagebMapper;
import com.yidu.t299.domain.xp.Class;
import com.yidu.t299.domain.xp.Record;
import com.yidu.t299.domain.xp.School;
import com.yidu.t299.domain.xp.StudentManage;
import com.yidu.t299.service.xp.StudentManagebBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * @descripion:
 * @auth: XuPan
 * @date: 2023/3/8 10:30
 * @version: 1.0
 */
@Service
@Transactional
public class StudentManagebBizImpl implements StudentManagebBiz {
    @Autowired
    private StudentManagebMapper studentMapper;//注入数据

    @Override
    public int deleteByPrimaryKey(Integer studentId) {
        return studentMapper.deleteByPrimaryKey(studentId);
    }

    @Override
    public int insert(StudentManage record) {
        return studentMapper.insert(record);
    }

    @Override
    public StudentManage selectByPrimaryKey(Integer studentId) {
        return studentMapper.selectByPrimaryKey(studentId);
    }

    @Override
    public List<StudentManage> selectByPage(int rows, int page, String condition) {
        return studentMapper.selectByPage(rows, page, condition);
    }

    @Override
    public int selectCount(String condition) {
        return studentMapper.selectCount(condition);
    }

    @Override
    public int updateByPrimaryKey(StudentManage record) {
        return studentMapper.updateByPrimaryKey(record);
    }




    @Override
    public int selectBySchoolName(String schoolName) {
        return studentMapper.selectBySchoolName(schoolName);
    }

    @Override
    public int selectByClassName(String className) {
        return studentMapper.selectByClassName(className);
    }

    @Override
    public int selectByRecordName(String recordName) {
        return studentMapper.selectByRecordName(recordName);
    }

    @Override
    public String getCondition(StudentManage student) {
        // 定义条件字符串变量，初始值为空格字符串
        String condition = " ";
        if (student.getStudentName() != null && student.getStudentName().trim().length()!=0){
            condition += " and student_name like '%" + student.getStudentName() + "%'";
        }
        //返回条件字符串
        return condition;
    }

    @Override
    public List<School> selectAllGetSchoolName() {
        return studentMapper.selectAllGetSchoolName();
    }

    @Override
    public List<Record> selectAllGetRecordName() {
        return studentMapper.selectAllGetRecordName();
    }

    @Override
    public List<Class> selectAllGetClassName() {
        return studentMapper.selectAllGetClassName();
    }
}
